using System.ComponentModel.DataAnnotations.Schema;

namespace Wips.Domain.Models.Authorities.Model
{
    /// <summary>
    /// 权限与操作关联
    /// </summary>
    [Table("AuthorityPermissionOperations")]
    [SugarTable("AuthorityPermissionOperations")]
    public class PermissionOperation : ValueObjectBase
    {
        /// <summary>
        /// 权限ID
        /// </summary>
        /// <value></value>
        public string PermissionId { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        /// <value></value>
        [Navigate(NavigateType.ManyToOne, nameof(PermissionId))]
        public Permission Permission { get; set; }

        /// <summary>
        /// 操作ID
        /// </summary>
        /// <value></value>
        public string OperationId { get; set; }

        /// <summary>
        /// 操作组
        /// </summary>
        /// <value></value>
        [Navigate(NavigateType.ManyToOne, nameof(OperationId))]
        public Operation Operation { get; set; }

        public PermissionOperation()
        {
        }

        public PermissionOperation(string permissionId, string operationId)
        {
            PermissionId = permissionId ?? throw new ArgumentNullException(nameof(permissionId));
            OperationId = operationId ?? throw new ArgumentNullException(nameof(operationId));
        }
    }
}